In typical digital processing applications, a digital signal is obtained that represents an analog signal. The digital signal is made up of a sequence of digital values, or samples, that represent the amplitude of the analog signal at regular intervals. The samples may be generated directly by a program or may be obtained by sampling an analog signal at regular intervals to produce a sequence of digital values. The digital signal may then be stored, modified, transmitted, or otherwise manipulated using digital techniques. The digital signal is then converted back into an analog signal.
As an example, an analog signal from a microphone is sampled to create a digital signal representative of a vocal track. The vocal track is then mixed with other sound tracks to create a song, which is then recorded onto an optical disk. During playback of the optical disk, a digital signal representing the recorded song is converted back into an analog signal and amplified to drive loudspeakers or headphones so that a user is able to hear the song.
Separate devices often perform the various processing steps described above. An analog-to-digital converter (ADC) converts the analog signal to a digital signal, a microprocessor or digital signal processor (DSP) processes the digital signal, and a digital-to-analog converter (DAC) converts the processed digital signal back into an analog signal. These devices often communicate among themselves using a serial interface to transfer the digital samples.
Converting sampled data from one word length to another is often desirable. In some instances, word length conversion is done to take advantage of hardware efficiencies that accrue when the data sample word length matches an intrinsic word length of a processor or other device. Many microprocessors and digital signal processors have native instructions for manipulating 8-bit or 16-bit data. Operating on data in native word sizes is more efficient than operating on non-native word sizes, since operating on non-native word sized data may require multiple instructions to perform the equivalent operation as a single instruction on native word sized data.
In other instances, word length conversion is done because a device is physically unable to process data of a given word size. For example, an ADC may be able to send 24-bit data words to a processor that is only able to receive 16-bit data words. Transmitting more bits than the hardware of the processor supports results in overflowing receive buffer of the processor and a loss of data.
One method of converting sampled data from one word size to another smaller word size is to simply truncate the larger data word to remove some of the low valued bits. However, truncation often results in undesirable distortion and quantization artifacts in the resulting digital signal. An improved method is to add a small amount of noise, also called dither, to the signal prior to truncation to reduce or minimize the distortion and quantization artifacts. The addition of dither to a signal prior to truncation is described more fully in U.S. Pat. No. 6,356,872 to Leung et al., which is incorporated herein by this reference in its entirety.
A method of converting sampled data to another larger word size is to simply shift the bits toward higher place values and fill in or pad the lower bits. The lower bits may be filled with zero bits or one bits. In some cases dither may be added to the lower bits of a lengthened sample word as disclosed in U.S. Pat. No. 6,356,872.
Previously, truncation and/or padding and the addition of dither is often done programmatically using a processor such as a DSP or microprocessor. This method required the presence of a suitably programmed processor to perform the conversion. The specific program needed depended on the difference in the word sizes, so that changes in the word length that a device used required changes in the software. Alternatively, custom hardware may be used to convert sample word length. However, such hardware would need to be redesigned if the word length of any underlying components were changed.
Methods and apparatuses for automatically converting sample word size when transmitting sample data from one device to another are desirable.
Automatically providing a correct amount of dither when converting sample data from one word length to another word length is also desirable.